package com.tile.gemo
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.text.TextField;
	
	public class BGtile extends Sprite
	{
		private var bgShape:Shape;
		public function BGtile()
		{
			super();
			initTile();
		}
		private function initTile():void{
			bgShape = new Shape;
			bgShape.graphics.beginFill(0x0000ff);
			this.addChild(bgShape);
			
			this.graphics.lineStyle(1,0x00ff00);
			for(var i:int=0;i<50;i++){
				drawLeftLine(64*i-32);
			}
			for(i=50;i>-50;i--){
				drawRightLine(64*i-32);
			}
			
			for(i=0;i<30;i++){
				for(var j:int=0;j<50;j++){
					var txt:TextField = new TextField;
					txt.width = 64;
					txt.height = 35;
					txt.selectable = false;
					if(i==7 && j==15)
						txt.htmlText = "<p align='center'><font face='Microsoft YaHei' color='#ff0000'>(" + i + "," + j + ")</font></p>";
					else
						txt.htmlText = "<p align='center'><font face='Microsoft YaHei'>(" + i + "," + j + ")</font></p>";
					this.addChild(txt);
					if(j%2)
						txt.x = 64*i + 32;
					else
						txt.x = 64*i;
					txt.y = 16*j + 5;
					drawCenter(i,j);
				}
			}
		}
		private function drawCenter(tx:int,ty:int):void{
			var p:Point = Util.getPixelPoint(tx,ty);
			bgShape.graphics.drawCircle(p.x,p.y,2);
		}
		private function drawLeftLine(x:int):void{
			this.graphics.moveTo(x,0);
			this.graphics.lineTo(-1400+x,700);
		}
		
		private function drawRightLine(x:int):void{
			this.graphics.moveTo(x,0);
			this.graphics.lineTo(1400+x,700);
		}
	}
}